Skip to content

bugfix(worldbuilder): fix optimized trees not being shown in object placer preview window#2312

Open
ViTeXFTW wants to merge 2 commits intoTheSuperHackers:mainfrom
ViTeXFTW:bugfix/tree-preview-object-placer
Open

bugfix(worldbuilder): fix optimized trees not being shown in object placer preview window#2312
ViTeXFTW wants to merge 2 commits intoTheSuperHackers:mainfrom
ViTeXFTW:bugfix/tree-preview-object-placer

Conversation

@ViTeXFTW
Copy link

Description
When making Zero Hour the devs created an optimized module (W3DTreeDraw) for drawing trees. They forgot to add the preview handling in WorldBuilder to handle this new draw type, which results in the preview not showing anything when having an object of the W3DTreeDraw module selected.

Root Cause
WorldBuilder attempts to get the module data for getting the model name of the object. However the format of the W3DModelDraw module data and W3DTreeDraw module data are different and there is not an exposed and generic way to get the information without explicitly casting the data to the expected type (W3DModelDrawModuleData or W3DTreeDrawModuleData).

Fix
Added a fallback function call to get the W3DTreeDrawModuleData if the normal W3DModelDraw fails which preserves the original behavior and also enables preview of tree types.

Old:
image

New:
image

@greptile-apps
Copy link

greptile-apps bot commented Feb 15, 2026

Greptile Summary

Adds fallback handling for W3DTreeDraw module in WorldBuilder's object preview system. When W3DModelDraw module data retrieval fails, the code now attempts to retrieve W3DTreeDraw module data and access its model name directly via m_modelName member. This fixes the bug where tree objects (using the optimized W3DTreeDraw module introduced in Zero Hour) would not display previews in the WorldBuilder object placer.

  • Added include for W3DTreeDraw.h header
  • Added fallback check for W3DTreeDrawModuleData after W3DModelDrawModuleData check
  • Uses direct member access to treeData->m_modelName since W3DTreeDrawModuleData lacks the getBestModelNameForWB() method
  • Preserves original behavior while extending support for tree draw modules
  • Previous review comments regarding spacing and brace placement have been addressed

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is a straightforward fallback mechanism that preserves existing behavior and follows established patterns in the codebase. The change is minimal (9 lines), well-documented, and addresses previous style feedback. The logic correctly mirrors the existing W3DModelDrawModuleData check pattern.
  • No files require special attention

Important Files Changed

Filename Overview
GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp Adds fallback to handle W3DTreeDraw module data when W3DModelDraw fails, enabling tree preview in WorldBuilder object placer

Last reviewed commit: 01e291e

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix makes sense.

Code style can be polished.

@xezon xezon added Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker WorldBuilder Relates to World Builder labels Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker WorldBuilder Relates to World Builder

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worldbuilder: Bug: Optimization made for trees in ZH broke the w3d model preview under ZH worldbuilder

2 participants